package com.aoip.telemetry.telemetry.configureui.framework.config.properties;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;

/**
 * CAS的配置参数
 */
@Component
public class CasProperties {
	@Value("${cas.server.url}")
	private String casServerUrl;

	@Value("${cas.server.login_url}")
	private String casServerLoginUrl;

	@Value("${cas.server.logout_url}")
	private String casServerLogoutUrl;

	@Value("${cas.server.casEnable}")
	private boolean casEnable;

	@Value("${cas.server.encoding}")
	private String encoding;

	@Value("${cas.server.web_url}")
	private String webUrl;

	@Value("${cas.server.user_name}")
	private String userName;

	@Value("${cas.server.pwd}")
	private String pwd;

	@Value("${cas.server.role_id}")
	private String roleId;


	@Value("${cas.server.user_name2}")
	private String userName2;

	@Value("${cas.server.pwd2}")
	private String pwd2;

	@Value("${cas.server.role_id2}")
	private String roleId2;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public String getRoleId() {
		return roleId;
	}

	public String getWebUrl() {
		return webUrl;
	}

	public String getCasServerUrl() {
		return casServerUrl;
	}

	public String getCasServerLoginUrl() {
		return casServerLoginUrl;
	}

	public String getEncoding() {
		return encoding;
	}

	public String getCasServerLogoutUrl() {
		return casServerLogoutUrl;
	}

	public boolean isCasEnable() {
		return casEnable;
	}

	public String getUserName2() {
		return userName2;
	}

	public String getPwd2() {
		return pwd2;
	}

	public String getRoleId2() {
		return roleId2;
	}

	@Value("${cas.server.ignorePattern}")
	private String ignorePattern;

	public String getIgnorePattern() {
		return ignorePattern;
	}

	public void setIgnorePattern(String ignorePattern) {
		this.ignorePattern = ignorePattern;
	}

	@Value("${cas.server.validate-filters}")
    private String validateFilters;

	@Value("${cas.server.sign-out-filters}")
    private String signOutFilters;

	@Value("${cas.server.auth-filters}")
    private String authFilters;

	@Value("${cas.server.assertion-filters}")
    private String assertionFilters;

	@Value("${cas.server.request-wrapper-filters}")
    private String requestWrapperFilters;

	@Value("${cas.server.server-name}")
	private String serverName;

	public String getServerName() {
		return serverName;
	}


    private boolean useSession = true;
    private boolean redirectAfterValidation = true;

	static final String separator = ",";
    public List<String> getValidateFilters() {
        return Arrays.asList(validateFilters.split(separator));
    }
    public List<String> getSignOutFilters() {
        return Arrays.asList(signOutFilters.split(separator));
    }
    public List<String> getAuthFilters() {
        return Arrays.asList(authFilters.split(separator));
    }
    public List<String> getAssertionFilters() {
        return Arrays.asList(assertionFilters.split(separator));
    }
    public List<String> getRequestWrapperFilters() {
        return Arrays.asList(requestWrapperFilters.split(separator));
    }

    public boolean isRedirectAfterValidation() {
        return redirectAfterValidation;
    }
    public boolean isUseSession() {
        return useSession;
    }

}
